package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysCgCpDim;
import com.ruoyi.system.service.ISysCgCpDimService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * SysCgCpDimController
 * 
 * @author SYF
 * @date 2025-05-06
 */
@RestController
@RequestMapping("/system/cpfb")
public class SysCgCpDimController extends BaseController {
    @Autowired
    private ISysCgCpDimService sysCgCpDimService;

    /**
     * 查询SysCgCpDim列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SysCgCpDim sysCgCpDim) {
        startPage();
        List<SysCgCpDim> list = sysCgCpDimService.selectSysCgCpDimList(sysCgCpDim);
        return getDataTable(list);
    }

    /**
     * 导出SysCgCpDim列表
     */
    @Log(title = "SysCgCpDim", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysCgCpDim sysCgCpDim) {
        List<SysCgCpDim> list = sysCgCpDimService.selectSysCgCpDimList(sysCgCpDim);
        ExcelUtil<SysCgCpDim> util = new ExcelUtil<SysCgCpDim>(SysCgCpDim.class);
        util.exportExcel(response, list, "产品底表数据");
    }

    /**
     * 获取SysCgCpDim详细信息
     */
    @GetMapping(value = "/{yongyouCode}")
    public AjaxResult getInfo(@PathVariable("yongyouCode") String yongyouCode)
    {
        return success(sysCgCpDimService.selectSysCgCpDimByYongyouCode(yongyouCode));
    }

    /**
     * 新增SysCgCpDim
     */
    @Log(title = "SysCgCpDim", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysCgCpDim sysCgCpDim)
    {
        return toAjax(sysCgCpDimService.insertSysCgCpDim(sysCgCpDim));
    }

    /**
     * 修改SysCgCpDim
     */
    @Log(title = "SysCgCpDim", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysCgCpDim sysCgCpDim)
    {
        return toAjax(sysCgCpDimService.updateSysCgCpDim(sysCgCpDim));
    }

    /**
     * 删除SysCgCpDim
     */
    @Log(title = "SysCgCpDim", businessType = BusinessType.DELETE)
	@DeleteMapping("/{yongyouCodes}")
    public AjaxResult remove(@PathVariable String[] yongyouCodes)
    {
        return toAjax(sysCgCpDimService.deleteSysCgCpDimByYongyouCodes(yongyouCodes));
    }
}
